
<script>
    var utOpts = {"0":"游戏接口","1":"后台接口"};
    var boolOpts = {"0":"禁止","1":"允许"};

    var navbarOpts = <%-JSON.stringify(ret.navbar)%>;
    var option = {
        colModel : [
            {label: 'id', name: '_id', width: 80,key:true, editable: false,sortable:true, resize:false,search:true,fixed:true},

            {label: '名称', name: 'name',width: 180, editable: true, sortable:false,hidden:false,resize:true,fixed:true,search:false},

            {label: '类型', name: 'ut',width: 120, editable: true, sortable:false,hidden:false,resize:false,fixed:true,search:false,
                formatter:'select', edittype:'select', editoptions:{value:utOpts},
                stype:"select",
            },

            {label: '菜单', name: 'mid',width: 120, editable: true, sortable:false,hidden:false,resize:false,fixed:true,search:true,
                formatter:'select', edittype:'select', editoptions:{value:navbarOpts},
                stype:"select",
                searchoptions:{value:navbarOpts}
            },

            

            {label: '添加', name: 'add',width: 60, editable: true, sortable:false,hidden:false,resize:false,fixed:true,search:false,
                formatter:'select', edittype:'select', editoptions:{value:boolOpts},
                stype:"select",
            },
            {label: '编辑', name: 'edit',width: 60, editable: true, sortable:false,hidden:false,resize:false,fixed:true,search:false,
                formatter:'select', edittype:'select', editoptions:{value:boolOpts},
                stype:"select",
            },
            {label: '删除', name: 'del',width: 60, editable: true, sortable:false,hidden:false,resize:false,fixed:true,search:false,
                formatter:'select', edittype:'select', editoptions:{value:boolOpts},
                stype:"select",
            },

            {label: '接口', name: 'api',width: 180, editable: true, sortable:false,hidden:false,resize:true,fixed:true,search:false},

            {label: '查询参数', name: 'query',width: 280, editable: true, sortable:false,hidden:false,resize:true,fixed:false,search:false},

            {label: '代码', name: 'script',width: 180, editable: true, sortable:false,hidden:true,resize:true,fixed:true,search:false,
                editrules: { edithidden: true },
                edittype:'textarea',editoptions:{rows:"8",cols:"70"},
            },
        ],

    }

    var NewNavbar = [
        {
            title:"表单字段",
            caption:"",
            position : "last",
            buttonicon:"octicon-gear",
            onClickButton: function(){
                var id=$(grid_selector).jqGrid("getGridParam","selrow");
                if(!id){
                    return layer.alert('请先选择一行数据');
                }
                var data = $(grid_selector).jqGrid("getRowData",id);
                var name = "表单字段 --> "+data['name'];
                var index = cosjs.layer.show(name,GURL('branch/forms/fields','index?fid='+id));
                layer.full(index);
            }
        }
    ]

    $(document).ready(function () {
        cosjs_create_jqgrid(option);
        for(var n of NewNavbar){
            $(grid_selector).jqGrid('navButtonAdd',pager_selector,n)
        }
    });
</script>